
package cn.edu.scau.cmi.hombio.domain;

import java.io.Serializable;

import java.lang.StringBuilder;

import java.util.Set;

import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import org.codehaus.jackson.annotate.JsonIgnore;

import javax.xml.bind.annotation.*;

import javax.persistence.*;

/**
 */

@Entity
@NamedQueries({
		@NamedQuery(name = "findAllInspectionExceptions", query = "select myInspectionException from InspectionException myInspectionException"),
		@NamedQuery(name = "findInspectionExceptionById", query = "select myInspectionException from InspectionException myInspectionException where myInspectionException.id = ?1"),
		@NamedQuery(name = "findInspectionExceptionByMemo", query = "select myInspectionException from InspectionException myInspectionException where myInspectionException.memo = ?1"),
		@NamedQuery(name = "findInspectionExceptionByMemoContaining", query = "select myInspectionException from InspectionException myInspectionException where myInspectionException.memo like ?1"),
		@NamedQuery(name = "findInspectionExceptionByPrimaryKey", query = "select myInspectionException from InspectionException myInspectionException where myInspectionException.id = ?1") })

@Table(catalog = "pig", name = "inspection_exception")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "pigRs/cn/edu/scau/cmi/hombio/domain", name = "InspectionException")

public class InspectionException implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 */

	@Column(name = "Id", nullable = false)
	@Basic(fetch = FetchType.EAGER)

	@Id @GeneratedValue
	@XmlElement
	Integer id;
	/**
	 */

	@Column(name = "Memo")
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	String memo;

	/**
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({ @JoinColumn(name = "ExceptionTypeId", referencedColumnName = "Id", nullable = false) })
	@XmlTransient
	ExceptionType exceptionType;
	/**
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({ @JoinColumn(name = "InspectionId", referencedColumnName = "Id", nullable = false) })
	@XmlTransient
	Inspection inspection;
	/**
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({ @JoinColumn(name = "PigstyId", referencedColumnName = "Id", nullable = false) })
	@XmlTransient
	Pigsty pigsty;

	/**
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 */
	public Integer getId() {
		return this.id;
	}

	/**
	 */
	public void setMemo(String memo) {
		this.memo = memo;
	}

	/**
	 */
	public String getMemo() {
		return this.memo;
	}

	/**
	 */
	public void setExceptionType(ExceptionType exceptionType) {
		this.exceptionType = exceptionType;
	}

	/**
	 */
	@JsonIgnore
	public ExceptionType getExceptionType() {
		return exceptionType;
	}

	/**
	 */
	public void setInspection(Inspection inspection) {
		this.inspection = inspection;
	}

	/**
	 */
	@JsonIgnore
	public Inspection getInspection() {
		return inspection;
	}

	/**
	 */
	public void setPigsty(Pigsty pigsty) {
		this.pigsty = pigsty;
	}

	/**
	 */
	@JsonIgnore
	public Pigsty getPigsty() {
		return pigsty;
	}

	/**
	 */
	public InspectionException() {
	}

	/**
	 * Copies the contents of the specified bean into this bean.
	 *
	 */
	public void copy(InspectionException that) {
		setId(that.getId());
		setMemo(that.getMemo());
		setExceptionType(that.getExceptionType());
		setInspection(that.getInspection());
		setPigsty(that.getPigsty());
	}

	/**
	 * Returns a textual representation of a bean.
	 *
	 */
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("id=[").append(id).append("] ");
		buffer.append("memo=[").append(memo).append("] ");

		return buffer.toString();
	}

	/**
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((id == null) ? 0 : id.hashCode()));
		return result;
	}

	/**
	 */
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof InspectionException))
			return false;
		InspectionException equalCheck = (InspectionException) obj;
		if ((id == null && equalCheck.id != null) || (id != null && equalCheck.id == null))
			return false;
		if (id != null && !id.equals(equalCheck.id))
			return false;
		return true;
	}
}
